﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using ZedGraph;
using System.Collections;

namespace sqxt
{
    public partial class person : Form
    {
        public person()
        {
            InitializeComponent();
        }
        string hno = "";
        public person(string s)
        {
            InitializeComponent();
            hno = s;
        }
        SqlConnection conn = new SqlConnection(Dbconnect.s1);
        DataTable dt;
        SqlDataReader sdr;
        SqlCommand sc;
        DataRow dr;
        string name = "";
        private void person_Load(object sender, EventArgs e)
        {

            try
            {
                ArrayList shoushuo = null; ;//收缩压
                ArrayList shuz = null; ;//舒张压
                ArrayList fpg = null; ;//尿糖
                #region 读取高血压随访血压值
                string sqlxy = "select followup_id  from followup where person_healthfile_no='" + hno + "'  and  real_followup_date is not null and followup_class  like '%高血压%'";
                try
                {
                    conn.Open();
                    ArrayList arr = new ArrayList();
                    sc = new SqlCommand(sqlxy, conn);
                    sdr = sc.ExecuteReader();
                    while (sdr.Read())
                    {
                        arr.Add("'" + sdr.GetString(0) + "'");
                    }
                    conn.Close();
                    sdr.Close();
                    string sqlss = "select 收缩压 from hypertension_visit_view  where  followup_id=";
                    shoushuo = new ArrayList();
                    for (int i = 0; i < arr.Count; i++)
                    {
                        string ss = zhixing(sqlss + arr[i].ToString());
                        shoushuo.Add(ss);//收缩压
                    }

                    string sz = "select 舒张压 from hypertension_visit_view  where  followup_id=";
                    shuz = new ArrayList();
                    for (int i = 0; i < arr.Count; i++)
                    {
                        string szy = zhixing(sz + arr[i].ToString());
                        shuz.Add(szy);//舒张压
                    }

                #endregion

                    #region  读取糖尿病尿糖值
                    string sqlxt = "select followup_id  from followup where person_healthfile_no='" + hno + "'  and  real_followup_date is not null and followup_class  like '%糖尿病%'";

                    conn.Open();
                    ArrayList arrnt = new ArrayList();
                    sc = new SqlCommand(sqlxt, conn);
                    sdr = sc.ExecuteReader();
                    while (sdr.Read())
                    {
                        arrnt.Add("'" + sdr.GetString(0) + "'");
                    }
                    conn.Close();
                    sdr.Close();

                    string sqlnt = "select [空腹血糖值(mmol/L)] from diabete_visit_view  where  followup_id=";
                    fpg = new ArrayList();
                    for (int i = 0; i < arrnt.Count; i++)
                    {
                        string sz1 = zhixing(sqlnt + arrnt[i].ToString());
                        fpg.Add(sz1);//血糖值
                    }
                }
                catch (Exception e1)
                {
                    
                }
                    #endregion



                #region  高血压曲线图
                GraphPane myPaneh = zgchypertension.GraphPane;
                myPaneh.Title.Text = "血压曲线图";
                myPaneh.XAxis.Title.Text = "测血压频率";
                myPaneh.YAxis.Title.Text = "血压值";
                PointPairList listh = new PointPairList();//数值
                PointPairList lisths = new PointPairList();//收缩压
                PointPairList lishsz = new PointPairList();//舒张压

                myPaneh.XAxis.CrossAuto = true;//自动设置原点
                for (int i = 0; i < 9; i++)
                {

                    double y = 100 + Math.Sin((double)i * 0.2);
                    double x = (double)i + 1;
                    listh.Add(x, y);
                }

                if (shoushuo.Count != 0)
                {
                    for (int i = 0; i < shoushuo.Count; i++)
                    {
                        lisths.Add((double)(i + 1), Convert.ToDouble(shoushuo[i]));
                    }
                }
                if (shuz.Count != 0)
                {
                    for (int i = 0; i < shuz.Count; i++)
                    {
                        lishsz.Add((double)(i + 1), Convert.ToDouble(shuz[i]));
                    }

                }


                LineItem myCurve = myPaneh.AddCurve("",
                     listh, Color.White, SymbolType.Circle);
                LineItem myCurves = myPaneh.AddCurve("收缩压",
                   lisths, Color.Red, SymbolType.Circle);
                LineItem myCurvesz = myPaneh.AddCurve("舒张压",
                   lishsz, Color.Blue, SymbolType.Circle);

                zgchypertension.AxisChange();
                #endregion

                #region  尿糖曲线图
                GraphPane myPaned = zgcdiabetes.GraphPane;
                myPaned.Title.Text = "尿糖曲线图";
                myPaned.XAxis.Title.Text = "测尿糖频率";
                myPaned.YAxis.Title.Text = "尿糖值";
                PointPairList listd = new PointPairList();//数值
                PointPairList listdnt = new PointPairList();//尿糖值

                myPaned.XAxis.CrossAuto = true;//自动设置原点
                for (int i = 0; i < 9; i++)
                {

                    double y = 100 + Math.Sin((double)i * 0.2);
                    double x = (double)i + 1;
                    listd.Add(x, y);
                }

                if (fpg.Count != 0)
                {
                    for (int i = 0; i < fpg.Count; i++)
                    {
                        listdnt.Add((double)(i + 1), Convert.ToDouble(fpg[i]));
                    }
                }
                LineItem myCurved = myPaned.AddCurve("",
                     listd, Color.White, SymbolType.Circle);

                LineItem myCurvednt = myPaned.AddCurve("",
                     listdnt, Color.Red, SymbolType.Circle);


                zgcdiabetes.AxisChange();
                #endregion



                #region  读取居民基本信息
                try
                {
                    conn.Open();
                    string cx = "select person_name,person_sex,person_birthdate,person_idtype,person_id_no,person_family_tel,Person_addr,person_healthfile_no,person_isend from person where  person_healthfile_no='" + hno.Trim() + "'";
                    SqlCommand sc = new SqlCommand(cx, conn);
                    SqlDataReader sdr = sc.ExecuteReader();
                    sdr.Read();
                    {
                        name = sdr[0].ToString();
                        label10.Text = sdr[0] is DBNull ? string.Empty : sdr.GetString(0);
                        label11.Text = sdr[1] is DBNull ? string.Empty : sdr.GetString(1);
                        int nl = DateTime.Now.Year - Convert.ToDateTime(sdr[2]).Year;
                        label12.Text = nl.ToString();
                        if (sdr[3].ToString() == "身份证")
                        {
                            label13.Text = sdr[4].ToString();
                        }
                        else
                        {
                            label13.Text = "";
                        }
                        label14.Text = hno;
                        label15.Text = "广东省东莞市大岭山镇" + sdr[6];
                        label16.Text = sdr[5] is DBNull ? string.Empty : sdr.GetString(5);
                        //label17.Text = sdr[8] is DBNull ? string.Empty : sdr.GetString(8);
                        if (sdr[8].ToString().Trim() == "未归档")
                        {
                            label18.Text = "活动";
                        }
                        else
                        {
                            label18.Text = "终结";
                        }

                        this.Text = sdr[0].ToString() + "的主页";
                    }
                    conn.Close();
                    sdr.Close();
                }
                catch (Exception e1)
                {
                    
                }
                finally
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
                #endregion
                this.readfollow();//读取随访信息
                this.readmingce();//读取名册信息

                label17.Text = mingce;
                SqlDataAdapter sda;
                #region 读长期性健康问题
                dt = new DataTable();
                string strSqlcq = "SELECT id, problem_describe  问题描述,problem_begintime 问题发生日期 from person_problem where problem_type='长期性健康问题'  and person_healthfile_no ='" + hno + "'";
                sda = new SqlDataAdapter(strSqlcq, conn);
                sda.Fill(dt);
                conn.Close();
                bindingSourcecqjkwt.DataSource = dt;
                dataGridViewX2.DataSource = bindingSourcecqjkwt;
                dataGridViewX5.DataSource = bindingSourcecqjkwt;
                dataGridViewX2.Columns[0].Visible = false;
                dataGridViewX5.Columns[0].Visible = false;
                #endregion

                #region 读暂时性健康问题
                dt = new DataTable();
                string strSqldq = "SELECT id, problem_describe  问题描述,problem_begintime 问题发生日期  from person_problem  where problem_type='暂时性健康问题'  and  person_healthfile_no ='" + hno + "'";
                sda = new SqlDataAdapter(strSqldq, conn);
                sda.Fill(dt);
                conn.Close();
                bindingSourcedqjkwt.DataSource = dt;
                dataGridViewX3.DataSource = bindingSourcedqjkwt;
                dataGridViewX6.DataSource = bindingSourcedqjkwt;
                dataGridViewX3.Columns[0].Visible = false;
                dataGridViewX6.Columns[0].Visible = false;
                #endregion

            }
            catch (Exception)
            {
            }

        }
        private void readfollow()  //读取随访信息
        {
            #region  读取个人的随访信息
            try
            {
                DataTable dt = new DataTable();
                string strSql = "SELECT complete 完成状态, person_name  姓名, person_sex 性别 ,followup_class 随访类型,person_healthfile_no 档案编号, next_followup_date 随访时间, person_family_tel 家庭电话, person_addr  家庭地址,followup_id from  vm_remind  where  person_healthfile_no ='" + hno + "'";
                SqlDataAdapter sda = new SqlDataAdapter(strSql, conn);
                sda.Fill(dt);
                conn.Close();
                bindingSource1.DataSource = dt;
                dataGridViewX1.DataSource = bindingSource1;
                dataGridViewX4.DataSource = bindingSource1;
                dataGridViewX1.Columns[8].Visible = false;
                dataGridViewX4.Columns[8].Visible = false;
            }
            catch (Exception e1)
            {
                
            }
            #endregion

        }


        public String zhixing(string s)//执行sql语句，返回值
        {
            conn.Close();
            conn.Open();
            SqlCommand   com = new SqlCommand(s, conn);
            string fh = com.ExecuteScalar().ToString();
            conn.Close();
            return fh;


        }



        string mingce = "";
        private void readmingce()//读取名册信息
        {
            try
            {
               
                dt = new DataTable();
                DataColumn dc = null;
                dc = dt.Columns.Add("mcclass", Type.GetType("System.String"));
                dc = dt.Columns.Add("createtime", Type.GetType("System.DateTime"));

                conn.Open();
                sc = new SqlCommand("select * from personfile1" + "  where person_healthfile_no='"+hno+"'", conn);
                sdr = sc.ExecuteReader();
                if (sdr.HasRows)
                {
                    ToolStripMenuItem1.Visible = false;
                    dr = dt.NewRow();
                    sdr.Read();
                    {
                        dr["mcclass"] = sdr["class"].ToString();
                        dr["createtime"] = sdr["create_time"];
                    }
                    dt.Rows.Add(dr);

                }
                conn.Close();
                conn.Open();
                sc = new SqlCommand("select * from elderly" + "  where person_healthfile_no='" + hno + "'", conn);
                sdr = sc.ExecuteReader();
                if (sdr.HasRows)
                {
                    ToolStripMenuItem2.Visible = false;
                    dr = dt.NewRow();
                    sdr.Read();
                    {
                    dr["mcclass"] = sdr["class"];
                    dr["createtime"] = sdr["create_date"];
                    dt.Rows.Add(dr);
                    mingce = mingce + "老";
                    }
                }
                conn.Close();
                conn.Open();
                sc = new SqlCommand("select * from hypertension" + "  where person_healthfile_no='" + hno + "'", conn);
                sdr = sc.ExecuteReader();
                if (sdr.HasRows)
                {
                    ToolStripMenuItem3.Visible = false;
                    dr = dt.NewRow();
                    sdr.Read();
                    {
                        dr["mcclass"] = sdr["class"];
                        dr["createtime"] = sdr["create_date"];
                        dt.Rows.Add(dr);
                        mingce = mingce + " 高";
                    }
                }
                conn.Close();
                conn.Open();
                sc = new SqlCommand("select * from diabetes" + "  where person_healthfile_no='" + hno + "'", conn);
                sdr = sc.ExecuteReader();
                if (sdr.HasRows)
                {
                    ToolStripMenuItem4.Visible = false;
                    dr = dt.NewRow();
                    sdr.Read();
                    {
                        dr["mcclass"] = sdr["class"];
                        dr["createtime"] = sdr["create_date"];
                        dt.Rows.Add(dr);
                        mingce=mingce+" 糖";
                    }
                }
                conn.Close();
                conn.Open();
                sc = new SqlCommand("select * from children" + "  where person_healthfile_no='" + hno + "'", conn);
                sdr = sc.ExecuteReader();
                if (sdr.HasRows)
                {
                    ToolStripMenuItem5.Visible = false;
                    dr = dt.NewRow();
                    sdr.Read();
                    {
                        dr["mcclass"] = sdr["class"];
                        dr["createtime"] = sdr["create_date"];
                        dt.Rows.Add(dr);
                        mingce = mingce + " 儿童";
                    }
                }
                conn.Close();

                conn.Open();
                sc = new SqlCommand("select * from woman" + "  where person_healthfile_no='" + hno + "'", conn);
                sdr = sc.ExecuteReader();
                if (sdr.HasRows)
                {
                    ToolStripMenuItem6.Visible = false;
                    dr = dt.NewRow();
                    sdr.Read();
                    {
                        dr["mcclass"] = sdr["class"];
                        dr["createtime"] = sdr["create_date"];
                        dt.Rows.Add(dr);
                        mingce = mingce + " 孕产妇";
                    }
                }
                conn.Close();

                conn.Open();
                sc = new SqlCommand("select * from theDisabled" + "  where person_healthfile_no='" + hno + "'", conn);
                sdr = sc.ExecuteReader();
                if (sdr.HasRows)
                {
                    ToolStripMenuItem7.Visible = false;
                    dr = dt.NewRow();
                    sdr.Read();
                    {
                        dr["mcclass"] = sdr["class"];
                        dr["createtime"] = sdr["create_date"];
                        dt.Rows.Add(dr);
                        mingce = mingce + " 残疾人";
                    }
                }
                conn.Close();

                sqda.DataSource = dt;
                
                //sqda.DataSource = dt;
                //sqda.DataSource = sqda;
            }
            catch (Exception e1)
            {
                
            }

        }

        private void label11_Click(object sender, EventArgs e)
        {

        }

        private void toolStripButton1_Click(object sender, EventArgs e)//执行随访计划
        {
            if (dataGridViewX1.Rows.Count > 0)
            {
                try
                {
                    string sta = dataGridViewX1.Rows[dataGridViewX1.CurrentRow.Index].Cells[0].Value.ToString();
                    string followupid = dataGridViewX1.Rows[dataGridViewX1.CurrentRow.Index].Cells[8].Value.ToString();
                    switch (dataGridViewX1.Rows[dataGridViewX1.CurrentRow.Index].Cells[3].Value.ToString().Trim())
                    {
                        case "健康体检":
                            if (sta.Trim() == "已完成")
                            {
                                bool ck = true;
                                physical_check phy = new physical_check(hno, name, followupid, ck);
                                phy.Show();
                            }
                            else
                            {
                                physical_check phy = new physical_check(hno, name, followupid);
                                phy.Show();
                            }

                            break;
                        case "孕产妇随访":
                            #region
                            conn.Open();
                            string dijici = "select count(*) from followup where  person_healthfile_no='" + hno + "'and followup_class='孕产妇随访'  and followup_id<='" + followupid + "'";
                            SqlCommand cicom = new SqlCommand(dijici, conn);
                            int folci = (int)cicom.ExecuteScalar();//判断followup_id在什么位置
                            conn.Close();
                            if (sta.Trim() == "已完成")
                            {

                                if (folci == 1)
                                {
                                    bool b = true;
                                    LactationWoman_visit1 lvs = new LactationWoman_visit1(followupid, name, hno, b);
                                    lvs.Show();
                                }
                                if (folci > 1 && folci < 6)//打开孕产妇随访表2用
                                {
                                    string twofol = "";
                                    conn.Open();
                                    SqlCommand sc11 = new SqlCommand("select max(followup_id) from  followup where followup_id in(select top 2 followup_id  from followup where person_healthfile_no='" + hno + "' and real_followup_date is not  null  and  followup_class='孕产妇随访') ", conn);
                                    SqlDataReader sdr11 = sc11.ExecuteReader();
                                    sdr11.Read();
                                    { twofol = sdr11[0].ToString(); }
                                    conn.Close();
                                    sdr11.Close();
                                    bool b = true;
                                    LactationWoman_visit2 lvs = new LactationWoman_visit2(twofol, name, hno, b);
                                    lvs.Show();
                                }
                                if (folci == 6)
                                {
                                    bool b = true;
                                    LactationWoman_visit3 lvs = new LactationWoman_visit3(followupid, name, hno, b);
                                    lvs.Show();
                                }


                            }
                            else
                            {
                                if (folci == 1)
                                {
                                    LactationWoman_visit1 lvs = new LactationWoman_visit1(followupid, name, hno);
                                    lvs.Show();
                                }
                                if (folci > 1 && folci < 6)
                                {

                                    string twofol = "";
                                    conn.Open();
                                    SqlCommand sc1 = new SqlCommand("select max(followup_id) from  followup where followup_id in(select top 2 followup_id  from followup where person_healthfile_no='" + hno + "' and real_followup_date is not  null  and  followup_class='孕产妇随访') ", conn);
                                    SqlDataReader sdr1 = sc1.ExecuteReader();
                                    sdr1.Read();
                                    { twofol = sdr1[0].ToString(); }
                                    conn.Close();
                                    sdr1.Close();
                                    bool b = true;
                                    LactationWoman_visit2 lvs = new LactationWoman_visit2(followupid, twofol, name, hno, b);
                                    lvs.Show();
                                }

                                if (folci == 6)
                                {
                                    LactationWoman_visit3 lvs = new LactationWoman_visit3(followupid, name, hno);
                                    lvs.Show();
                                }
                            }
                            #endregion
                            break;
                        case "老年人随访":
                            if (sta.Trim() == "已完成")
                            {
                                bool ck = true;
                                physical_check phy = new physical_check(hno, name, followupid, ck);
                                phy.Show();
                            }
                            else
                            {
                                string l = "老";
                                physical_check phy = new physical_check(hno, name, followupid, l);
                                phy.Show();
                            }
                            break;
                        case "残疾人随访":

                            if (sta.Trim() == "已完成")
                            {
                                bool ck = true;
                                physical_check phy = new physical_check(hno, name, followupid, ck);
                                phy.Show();
                            }
                            else
                            {
                                string l = "残";
                                physical_check phy = new physical_check(hno, name, followupid, l);
                                phy.Show();
                            }
                            break;

                        case "高血压患者随访":
                            if (sta.Trim() == "已完成")
                            {
                                Hypertension_visit db_visit = new Hypertension_visit(followupid);
                                db_visit.Show();
                            }
                            else
                            {
                                Hypertension_visit db_visit = new Hypertension_visit(name, hno, followupid);
                                db_visit.Show();

                            }

                            break;

                        case "2型糖尿病患者随访":
                            if (sta.Trim() == "已完成")
                            {
                                diabete_visit db_visit = new diabete_visit(followupid);
                                db_visit.Show();
                            }
                            else
                            {
                                diabete_visit db_visit = new diabete_visit(name, hno, followupid);
                                db_visit.Show();

                            }
                            break;
                    }
                }catch(Exception)
                {
                }
               
            }
            else
            {
                MessageBox.Show("请选择一条记录");
            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (dataGridViewX1.Rows.Count > 0)
            {
                if (dataGridViewX1.Rows[dataGridViewX1.CurrentRow.Index].Cells[0].Value.ToString() == "未完成")
                {
                    string id = dataGridViewX1.Rows[dataGridViewX1.CurrentRow.Index].Cells[4].Value.ToString();
                    string riqi = dataGridViewX1.Rows[dataGridViewX1.CurrentRow.Index].Cells[5].Value.ToString();
                    remind_rework rr = new remind_rework(id, riqi);
                    rr.ShowDialog();
                }
                else
                {
                   MessageBox.Show( "已完成的随访记录不可以修改随访日期");
                }
            }
            else
            {
                MessageBox.Show("请选择一条记录");
            }
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            this.readfollow();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedTab.Visible = false;
        }

        private void buttonItem1_Click(object sender, EventArgs e)
        {
            tabControl1.Tabs[0].Visible = true;
            tabControl1.SelectedTab = tabControl1.Tabs[0];
        }

        private void buttonItem2_Click(object sender, EventArgs e)
        {
            tabControl1.Tabs[1].Visible = true;
            tabControl1.SelectedTab = tabControl1.Tabs[1];
        }

        private void buttonItem3_Click(object sender, EventArgs e)
        {
            tabControl1.Tabs[2].Visible = true;
            tabControl1.SelectedTab = tabControl1.Tabs[2];
        }

        private void buttonItem4_Click(object sender, EventArgs e)
        {
            tabControl1.Tabs[3].Visible = true;
            tabControl1.SelectedTab = tabControl1.Tabs[3];
        }

        private void toolStripButton8_Click(object sender, EventArgs e)//退出
        {
            tabControl1.SelectedTab.Visible = false;
        }

        private void toolStripDropDownButton1_Click(object sender, EventArgs e)//新增
        {
            this.readmingce();
        }

       
        private void toolStripButton12_Click(object sender, EventArgs e)//退出
        {
            tabControl1.SelectedTab.Visible = false;
        }

      
        private void toolStripButton7_Click(object sender, EventArgs e)
        {

        }

      

        private void ToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            personfile p = new personfile(hno);
            p.Show();
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
             
            if (sqda.Rows.Count == 0)
            {
                MessageBox.Show("该居民未建立任何名册");
            }
            else
            {
                switch (sqda.Rows[sqda.CurrentRow.Index].Cells[0].Value.ToString().Trim())
                {
                    case "个人一般情况表":
                        bool chakan = true;
                        personfile pf = new personfile(chakan,hno);
                        pf.Show();

                        break;
                    case "高血压名册":

                        break;
                    case "糖尿病名册":

                        break;
                    case "老年人名册":
                        TheOldsAlter alt = new TheOldsAlter(hno);
                        alt.ShowDialog();
                        break;
                    case "儿童名册":

                        break;
                    case  "孕产妇名册":
                        LatactionAlter lalt = new LatactionAlter(hno);
                        lalt.ShowDialog();
                        break;
                    case "残疾人名册":
                        TheDisabledAlter ad = new TheDisabledAlter(hno);
                        ad.ShowDialog();
                        break;

                }
            
        }

        }

        private void toolStripButton5_Click(object sender, EventArgs e)//归档
        {
            #region  更新person表的isend记录
            SqlDataAdapter sda = new SqlDataAdapter("select * from person", Dbconnect.s1);
            DataTable dtxg = new DataTable();
            sda.Fill(dtxg);
            dtxg.PrimaryKey = new DataColumn[] { dtxg.Columns[0] };
            DataRow drxg = dtxg.Rows.Find(hno);
            drxg["person_isend"] = "归档";
            SqlCommandBuilder scbxg = new SqlCommandBuilder(sda);
            sda.Update(new DataRow[] { drxg });
            MessageBox.Show("该居民已归档，不用再进行随访等相关管理");
            #endregion
        }

        private void toolStripButton9_Click(object sender, EventArgs e)//增加长期健康问题
        {
            health_problem hp = new health_problem(hno);
            hp.ShowDialog();
        }

        private void toolStripButton13_Click(object sender, EventArgs e)
        {
            health_problem hp = new health_problem(hno);
            hp.ShowDialog();

        }

        private void toolStripButton10_Click(object sender, EventArgs e)//主要健康问题修改
        {

            if (dataGridViewX5.Rows.Count > 0)
            {
                bool xiugai = true;
                int id =Convert.ToInt32(dataGridViewX5.Rows[dataGridViewX5.CurrentRow.Index].Cells[0].Value);
                health_problem hp = new health_problem(id,xiugai);
                hp.ShowDialog();
                    
            }
            else
            {
                MessageBox.Show("请选择一条记录");
            }
        }

        private void toolStripButton14_Click(object sender, EventArgs e)//修改暂时健康问题
        {

            if (dataGridViewX6.Rows.Count > 0)
            {
                bool xiugai = true;
                int id = Convert.ToInt32(dataGridViewX6.Rows[dataGridViewX6.CurrentRow.Index].Cells[0].Value);
                health_problem hp = new health_problem(id, xiugai);
                hp.ShowDialog();

            }
            else
            {
                MessageBox.Show("请选择一条记录");
            }

        }

        private void toolStripButton15_Click(object sender, EventArgs e)//删除短期健康问题
        {

            if (dataGridViewX6.Rows.Count > 0)
            {
                conn.Open();
                string id = dataGridViewX6.Rows[dataGridViewX6.CurrentRow.Index].Cells[0].Value.ToString();
                SqlCommand com = new SqlCommand("delete from person_problem where id=" + id + "", conn);
                com.ExecuteNonQuery();
                conn.Close();
            }
            else
            {
                MessageBox.Show("请选择一条记录");
            }

        }

        private void toolStripButton11_Click(object sender, EventArgs e)//删除长期健康问题
        {
            if (dataGridViewX5.Rows.Count > 0)
            {
                conn.Open();
                string id = dataGridViewX5.Rows[dataGridViewX5.CurrentRow.Index].Cells[0].Value.ToString();
                SqlCommand com = new SqlCommand("delete from person_problem where id=" + id + "", conn);
                com.ExecuteNonQuery();
                conn.Close();
            }
            else
            {
                MessageBox.Show("请选择一条记录");
            }
        }

        private void ToolStripMenuItem2_Click(object sender, EventArgs e)//新增老年人名称
        {
            TheOldsAdd add = new TheOldsAdd();
            add.ShowDialog();

        }

        private void ToolStripMenuItem6_Click(object sender, EventArgs e)//新增孕产妇
        {
            LactationAdd add = new LactationAdd();
            add.ShowDialog();
        }

        private void toolStripDropDownButton1_Click_1(object sender, EventArgs e)//点击发生下拉控件
        {
            this.readmingce();
        }

        private void ToolStripMenuItem7_Click(object sender, EventArgs e)
        {
            TheDisabledAdd ad = new TheDisabledAdd();
            ad.ShowDialog();
        }

        private void ToolStripMenuItem3_Click(object sender, EventArgs e)//高血压名册
        {
            HypertensionAdd hyad = new HypertensionAdd();
            hyad.ShowDialog();

        }

        private void ToolStripMenuItem4_Click(object sender, EventArgs e)//糖尿病名册
        {
            DiabetesAdd diad = new DiabetesAdd();
            diad.ShowDialog();

        }

        private void ToolStripMenuItem5_Click(object sender, EventArgs e)//儿童名册
        {
            ChildrenAdd chad = new ChildrenAdd();
            chad.ShowDialog();
        }

       

        
    }
}